package com.itheima.service.impl;

import com.itheima.mapper.AccountMapper;
import com.itheima.service.AccountService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

//存入ioc
@Service
public class AccountServiceImpl  implements AccountService {
    //创建数据层对象 从spring ioc容器中取值给accountMapper
    @Autowired
    private AccountMapper accountMapper;


    public void transfer(String sname, String tname, Double money) {

        //转入  tname转出钱的人
        accountMapper.inUpdate(tname, money);
        //制造异常
//      int i = 1 / 0;

        //转出 sname 转出钱的人
        accountMapper.outUpdate(sname,money);
    }
}
